package com.xd.clap.entity.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xd.clap.entity.Task;
import com.xd.clap.entity.TaskAllocation;
import lombok.Data;

import java.util.Date;
import java.util.List;

@Data
public class TaskListVO {

    //任务id
    private Integer id;

    //位置
    private String location;

    //详细位置
    private String fullAddress;

    //任务内容
    private String content;

    //任务图片
    private String taskImg;

    //上传时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date createTime;

    //上传人
    private String createBy;

    //已处理任务数量
    private Integer processed;

    //任务人数
    private Integer totalCount;

    //任务人信息
    private List<TaskAllocation> taskAllocations;

    public static TaskListVO of(Task task, Integer totalCount, Integer processedCount,List<TaskAllocation> taskAllocations) {
        TaskListVO taskVO = new TaskListVO();
        taskVO.setId(task.getId());
        taskVO.setLocation(task.getLocation());
        taskVO.setFullAddress(task.getFullAddress());
        taskVO.setContent(task.getContent());
        taskVO.setTaskImg(task.getTaskImg());
        taskVO.setCreateTime(task.getCreateTime());
        taskVO.setCreateBy(task.getCreateBy());
        taskVO.setProcessed(processedCount);
        taskVO.setTotalCount(totalCount);
        taskVO.setTaskAllocations(taskAllocations);
        return taskVO;
    }
}
